package leetcode_core.dao.impl;

import leetcode_core.dao.OrderDAO;
import leetcode_core.domain.Order;
import leetcode_core.utils.MySqlSessionFactory;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年01月07日 11:17
 */
public class OrderDAOImpl implements OrderDAO {
    @Override
    public void insertOrder(Order order) {
        String sql = "insert into order values(null,?,?)";
        Connection connection = MySqlSessionFactory.getConnection();
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,order.getStudentId());
            preparedStatement.setString(2,order.getClassId());
            preparedStatement.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
